import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    imgBase: "http://juanxincai.zyxj888.top/",
    loginuname: sessionStorage.getItem("uname"),
  },
  getters: {},
  mutations: {
    // 登录的时候修改存储的uname值
    updateLoginState(state, payload) {
      state.loginuname = payload;
      // 将用户名存入sessionStorage,刷新网页依然存在
      sessionStorage.setItem("uname", payload);
    },
    // 点击退出登录
    login(state) {
      state.loginuname = state;
      sessionStorage.removeItem("uname");
    },
  },
  actions: {},
  modules: {},
});
